package com.job.controller;

import com.job.common.ResponseResult;
import com.job.common.exception.ParameterIsNullException;
import com.job.controller.req.StudentCertificateVO;
import com.job.controller.req.UploadVO;
import com.job.pojo.*;
import com.job.pojo.vo.StudentVO;
import com.job.service.StudentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jetbrains.annotations.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;

@RestController
@Api("学生接口")
@RequestMapping("/student")
@Validated
public class StudentController {

    @Resource
    private StudentService studentService;

    @ApiOperation("查询学生基本信息")
    @GetMapping("/studentInfo/query")
    public ResponseResult<StudentVO> studentInfoQuery(@NotNull @RequestParam("studentId") String studentId){
        return studentService.studentInfoQuery(studentId);
    }

    @ApiOperation("查询学生实习经历")
    @GetMapping("/workInfo/query")
    public ResponseResult<List<WorkInfo>> studentWorkInfoQuery(@NotNull @RequestParam("studentId") String studentId){
        return studentService.studentWorkInfoQuery(studentId);
    }

    @ApiOperation("查询学生项目经历")
    @GetMapping("/productInfo/query")
    public ResponseResult<List<Product>> studentProductInfoQuery(@NotNull @RequestParam("studentId") String studentId){
        return studentService.studentProductInfoQuery(studentId);
    }

    @ApiOperation("查询学生教育经历")
    @GetMapping("/education/query")
    public ResponseResult<List<Education>> studentEducationQuery(@NotNull @RequestParam("studentId") String studentId){
        return studentService.studentEducationQuery(studentId);
    }

    @ApiOperation("查询学生资格证书")
    @GetMapping("/certificate/query")
    public ResponseResult<List<Certificate>> studentCertificateQuery(@NotNull @RequestParam("studentId") String studentId){
        return studentService.studentCertificateQuery(studentId);
    }

    @ApiOperation("编辑学生基础信息")
    @PostMapping("/studentInfo/update")
    public ResponseResult<Student> studentInfoUpdate(@Valid @RequestBody Student student){
        return studentService.studentInfoUpdate(student);
    }

    @ApiOperation("编辑学生实习经历")
    @PostMapping("/workInfo/update")
    public ResponseResult<WorkInfo> studentWorkInfoUpdate(@RequestBody WorkInfo workInfo){
        return studentService.studentWorkInfoUpdate(workInfo);
    }

    @ApiOperation("编辑学生项目经验")
    @PostMapping("/productInfo/update")
    public ResponseResult<Product> studentProductInfoUpdate(@RequestBody Product product){
        return studentService.studentProductInfoUpdate(product);
    }

    @ApiOperation("编辑学生教育经历")
    @PostMapping("/education/update")
    public ResponseResult<Education> studentEducationUpdate(@RequestBody Education education){
        return studentService.studentEducationUpdate(education);
    }

    @ApiOperation("新增学生实习经历")
    @PostMapping("/workInfo/add")
    public ResponseResult<WorkInfo> studentWorkInfoAdd(@RequestBody WorkInfo workInfo){
        return studentService.studentWorkInfoAdd(workInfo);
    }

    @ApiOperation("新增学生项目经验")
    @PostMapping("/productInfo/add")
    public ResponseResult<Product> studentProductInfoAdd(@Validated @RequestBody Product product){
        return studentService.studentProductInfoAdd(product);
    }

    @ApiOperation("新增学生教育经历")
    @PostMapping("/education/add")
    public ResponseResult<Education> studentEducationAdd(@RequestBody Education education){
        return studentService.studentEducationAdd(education);
    }


    @GetMapping("/edit/advantage")
    public ResponseResult editAdvantage(String studentId, String advantage){
        return studentService.editAdvantage(studentId,advantage);
    }

    @GetMapping("/query/advantage")
    public ResponseResult<String> queryAdvantage(String studentId){
        return studentService.queryAdvantage(studentId);
    }

    @ApiOperation("新增学生资格证书")
    @PostMapping("/certificate/add")
    public ResponseResult<Certificate> studentCertificateAdd(@Validated @RequestBody StudentCertificateVO certificateVO){
        return studentService.studentCertificateAdd(certificateVO);
    }

    @ApiOperation("删除学生实习经历")
    @DeleteMapping("/workInfo/delete")
    public ResponseResult<WorkInfo> studentWorkInfoDelete(@NotNull String id){
        return studentService.studentWorkInfoDelete(id);
    }

    @ApiOperation("删除学生项目经历")
    @DeleteMapping("/productInfo/delete")
    public ResponseResult<Product> studentProductInfoDelete(@NotNull String id){
        return studentService.studentProductInfoDelete(id);
    }

    @ApiOperation("删除学生教育经历")
    @DeleteMapping("/education/delete")
    public ResponseResult<Education> studentEducationDelete(@NotNull String id){
        return studentService.studentEducationDelete(id);
    }

    @ApiOperation("删除学生资格证书")
    @DeleteMapping("/certificate/delete")
    public ResponseResult<Certificate> studentCertificateDelete(@Validated StudentCertificateVO certificateVO){
        return studentService.studentCertificateDelete(certificateVO);
    }

    @ApiOperation("上传简历")
    @PostMapping("/upload/file")
    public ResponseResult studentUpload(UploadVO uploadVO)
            throws IOException, ParameterIsNullException {
        return studentService.studentUploadFile(uploadVO.getStudentId(),uploadVO.getMultipartFile());
    }
}
